﻿
    <% var parents = _.filter(Items, function(category){ return category.ParentId == 0 ;});%>
    <% if (parents.length) { %>
    <ul>
        <%_.each(parents, function(parent) {%>
            <li class="parent"><a href="#"><%=parent.Name%></a>
                <% var children = _.filter(Items, function(category) { return category.ParentId == parent.CategoryId }); %>
                <% if (children.length) { %>
                <ul>
                    <%_.each(children, function(child) {%>
                        <li class="child"><a href="#"><%=child.Name%></a></li>
                    <% }); %>
                </ul>
                <% } %>
            </li>
        <% }); %>
    </ul>
    <% } %>


